package com.oracle.sbdb.testother;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.oracle.sbdb.dao.SessionFactory;

public class SessionFactoryTest {

	@Test
	public void test() {
		long startTime = System.currentTimeMillis();
		List<SqlSession> sessionList = new ArrayList<SqlSession>();
		try{
			for(int i = 0; i < 1; i++){
				System.out.print("Opening session "+(i+1)+"  ...   ");
				SqlSession session = SessionFactory.getSession();
				sessionList.add(session);
				System.out.println("Complete!");
			}
			
			for(int i = 0; i < sessionList.size(); i++){
				SqlSession session = sessionList.get(i);
				session.selectOne("com.oracle.mybatis.BugInfoMapper.selectBugInfobyBugId", 0);
			}
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			for(int i = 0; i < sessionList.size(); i++){
				SqlSession session = sessionList.get(i);
				System.out.print("Closing session " + (i + 1)+"\n");
				try{
					session.close();
				}catch(Exception e){
					e.printStackTrace();
				}
			}
		}
		long endTime = System.currentTimeMillis();
		System.out.println("Total time: " + (endTime - startTime));
	}

}
